package com.abner.activiti.zip;

import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;

import java.io.*;
import java.util.zip.ZipInputStream;

/**
 * @description: 使用zip文件创建流程
 * @author: guoc
 * @createDate: 2020/9/10 15:10
 */
public class activitiDeploymentByzip {

    public static void main(String[] args) {
        activitiDeploymentByzip activitiDeploymentByzip = new activitiDeploymentByzip();
        activitiDeploymentByzip.deploymentByZip();
    }

    public void deploymentByZip(){
        //获取zip
        InputStream resourceAsStream = activitiDeploymentByzip.class.getClassLoader().getResourceAsStream("designer/game.zip");

        ZipInputStream zipInputStream = new ZipInputStream(resourceAsStream);
        //流程引擎
        ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
        RepositoryService repositoryService = processEngine.getRepositoryService();
        Deployment deploy = repositoryService.createDeployment().addZipInputStream(zipInputStream).name("修罗").deploy();
        System.out.println("流程ID"+deploy.getId());
        System.out.println("流程名字"+deploy.getName());
    }

}
